package study.sharding.shardingjdbc.support.transaction;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

@Slf4j
@Configuration
public class TransactionConfig {

    @Autowired
    private DataSource dataSource;
    @Autowired
    private PlatformTransactionManager transactionManager;

    @PostConstruct
    public void init() {
        log.info(">>>>>>");
        log.info(">>>>>> {}", transactionManager.getClass().getSimpleName());
        log.info(">>>>>>");
    }

//    @Bean("transactionManager")
//    public PlatformTransactionManager transactionManager() {
//        log.info(">>>>>> {}", dataSource.getClass().getName());
//        return new DataSourceTransactionManager(dataSource);
//    }
}
